﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using LiveCharts.Definitions.Series;
using LiveCharts.SeriesAlgorithms;
using LiveCharts.Wpf;

namespace LiveCharts.Wpf
{
	public class GVerticalStackedAreaSeries : GVerticalLineSeries, ISeriesView, ILineSeriesView, IStackModelableSeriesView, IVerticalStackedAreaSeriesView
	{
		public GVerticalStackedAreaSeries()
		{
			base.Model = new VerticalStackedAreaAlgorithm(this);
			this.method_1();
		}

		public GVerticalStackedAreaSeries(object configuration)
		{
			base.Model = new VerticalStackedAreaAlgorithm(this);
			base.Configuration = configuration;
			this.method_1();
		}
 
		public StackMode StackMode
		{
			get
			{
				return (StackMode)base.GetValue(GVerticalStackedAreaSeries.StackModeProperty);
			}
			set
			{
				base.SetValue(GVerticalStackedAreaSeries.StackModeProperty, value);
			}
		}

		public override void OnSeriesUpdateStart()
		{
			base.ActiveSplitters = 0;
			if (base.SplittersCollector == 2147483646)
			{
				base.Splitters.ForEach(lss=>lss.SplitterCollectorIndex=0);
				base.SplittersCollector = 0;
			}
			int splittersCollector = base.SplittersCollector;
			base.SplittersCollector = splittersCollector + 1;
			if (base.Figure != null && base.Values != null)
			{
				double y = ChartFunctions.ToDrawMargin(base.Values.GetTracker(this).YLimit.Min, AxisOrientation.Y, base.Model.Chart, base.ScalesYAt);
				if (base.Model.Chart.View.DisableAnimations)
				{
					base.Figure.StartPoint = new Point(0.0, y);
				}
				else
				{
					base.Figure.BeginAnimation(PathFigure.StartPointProperty, new PointAnimation(new Point(0.0, y), base.Model.Chart.View.AnimationsSpeed));
				}
			}
			if (base.IsPathInitialized)
			{
				base.Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(base.Path);
				base.Path.Stroke = base.Stroke;
				base.Path.StrokeThickness = base.StrokeThickness;
				base.Path.Fill = base.Fill;
				base.Path.Visibility = base.Visibility;
				base.Path.StrokeDashArray = base.StrokeDashArray;
				return;
			}
			base.IsPathInitialized = true;
			base.Path = new Path
			{
				Stroke = base.Stroke,
				StrokeThickness = base.StrokeThickness,
				Fill = base.Fill,
				Visibility = base.Visibility,
				StrokeDashArray = base.StrokeDashArray
			};
			Panel.SetZIndex(base.Path, Panel.GetZIndex(this));
			PathGeometry pathGeometry = new PathGeometry();
			base.Figure = new PathFigure();
			pathGeometry.Figures.Add(base.Figure);
			base.Path.Data = pathGeometry;
			base.Model.Chart.View.AddToDrawMargin(base.Path);
			double y2 = ChartFunctions.ToDrawMargin(base.ActualValues.GetTracker(this).YLimit.Min, AxisOrientation.Y, base.Model.Chart, base.ScalesYAt);
			base.Figure.StartPoint = new Point(0.0, y2);
			int num = base.Model.Chart.View.Series.IndexOf(this);
			Panel.SetZIndex(base.Path, base.Model.Chart.View.Series.Count - num);
		}

		// Token: 0x060001A6 RID: 422 RVA: 0x0000B51C File Offset: 0x0000971C
		private void method_1()
		{
			base.SetCurrentValue(LineSeries.LineSmoothnessProperty, 0.7);
			base.SetCurrentValue(LineSeries.PointGeometrySizeProperty, 0.0);
			base.SetCurrentValue(LineSeries.PointForegroundProperty, Brushes.White);
			base.SetCurrentValue(Series.ForegroundProperty, new SolidColorBrush(Color.FromRgb(229, 229, 229)));
			base.SetCurrentValue(Series.StrokeThicknessProperty, 0.0);
			base.SetCurrentValue(GVerticalStackedAreaSeries.StackModeProperty, StackMode.Values);
			Func<ChartPoint, string> value = new Func<ChartPoint, string>(this.method_2);
			base.SetCurrentValue(Series.LabelPointProperty, value);
			base.DefaultFillOpacity = 1.0;
			base.Splitters = new List<LineSegmentSplitter>();
			
		}

		// Token: 0x060001A8 RID: 424 RVA: 0x0000314C File Offset: 0x0000134C
		[CompilerGenerated]
		private string method_2(ChartPoint chartPoint_0)
		{
			return base.Model.CurrentXAxis.GetFormatter()(chartPoint_0.X);
		}

		// Token: 0x0400011F RID: 287
		public static readonly DependencyProperty StackModeProperty = DependencyProperty.Register("StackMode", typeof(StackMode), typeof(GVerticalStackedAreaSeries), new PropertyMetadata(StackMode.Values));
	}
}
